<?php

namespace Database\Seeders;

use App\Kuafu\Brand\Model\Brand;
use App\Kuafu\Product\Model\Product;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class ProductsSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $insertArr = [
            [
                'id'          => 10,
                'menuId'      => 0,
                'brandId'     => 10,
                'categoryId'  => 1,
                'name'        => '夸父大鱿鱼',
                'desc'        => '夸父大鱿鱼',
                'imageUrl'    => 'https://www.51kuafu.com/file/storage/image/202101221113498a86f7071.jpg',
                'unit'        => '串',
                'price'       => 100,
                'costPrice'   => 1,
                'vipPrice'    => 1,
                'sort'        => 1,
                'isHot'       => 1,
                'isRecommend' => 1,
                'status'      => 1,
                'isDeleted'   => 0,
                'createdAt'   => time(),
                'updatedAt'   => time()
            ],
            [
                'id'          => 10,
                'menuId'      => 1,
                'brandId'     => 10,
                'categoryId'  => 1,
                'name'        => '夸父大鱿鱼',
                'desc'        => '夸父大鱿鱼',
                'imageUrl'    => 'https://www.51kuafu.com/file/storage/image/202101221113498a86f7071.jpg',
                'unit'        => '串',
                'price'       => 100,
                'costPrice'   => 1,
                'vipPrice'    => 1,
                'sort'        => 1,
                'isHot'       => 1,
                'isRecommend' => 1,
                'status'      => 1,
                'isDeleted'   => 0,
                'createdAt'   => time(),
                'updatedAt'   => time()
            ]
        ];

        $table = Product::query()->getModel()->getTable();
        DB::table($table)->whereIn('id', [10])->delete();
        DB::table($table)->insert($insertArr);

    }
}
